import base_api
import numpy
import pickle
from sdk_array_newsystem import SDKArray
obj = base_api.BaseAPI()
array = SDKArray(0)

# obj.devInit()
print('Dev init')
chipNum = 0
obj.selectChip(chipNum)
print('Chip Num = %d' % chipNum)
def pickle_load(file, **kwargs):
    with open(file, 'rb') as f:
        return pickle.load(f, **kwargs)

#print(weight_)
weight_2 = pickle_load('../mnist_demo/weight_chip_12_22.pkl')
print(weight_2['10'][0].shape)
print(weight_2['11'][0].shape)
w21= weight_2['10'][0]
w22= weight_2['11'][0]

for i in range(5):
    array.set_weight(w22,(484,92,92,10))
for i in range(5):   
    array.set_weight(w21,(0,0,484,92))

print("finish")

'''
row=484
col=92
n=5
m=10
for i in range(row,row+n):
    for j in range(col,col+m):
        ret=obj.calcOneCell(i, j)
        #ret=obj.readOneCell(i,j,'NEG')
        print(ret,end=" ")
    print()
'''